package com.orange.community.entity;

import lombok.Data;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

/**
 * @author GaryGyp
 * @Description: 社区讨论帖子
 * 在每个元素上面加上注解是为了与 es 产生联系
 */
@Data
@ToString
@Document(indexName = "discusspost", type = "_doc", shards = 6, replicas = 3)
public class DiscussPost {

    // 帖子id
    @Id
    private int id;

    // 用户id
    @Field(type = FieldType.Integer)
    private int userId;

    // 帖子标题
    // analyzer = "ik_max_word"：在搜索时将单词拆分成最多的部分
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String title;

    // 帖子内容
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String content;

    // 帖子类型
    @Field(type = FieldType.Integer)
    private int type;

    // 帖子状态
    @Field(type = FieldType.Integer)
    private int status;

    // 帖子创建日期
    @Field(type = FieldType.Date)
    private Date createTime;

    // 帖子评论数量
    @Field(type = FieldType.Integer)
    private int commentCount;

    // 帖子得分
    @Field(type = FieldType.Double)
    private double score;

}
